﻿#pragma once
#include "yzrutil.h"
#include "util/ParamRegister.h"

namespace yzrilyzr_dsp{
	ECLASS(DSP, public yzrilyzr_util::ParamRegister){
	public:
	virtual ~DSP(){}
	virtual std::shared_ptr<DSP> cloneDSP()=0;
	virtual void cloneParam(DSP * obj1)=0;
	//初始化参数
	virtual void init(u_sample_rate sampleRate)=0;
	//重置内部记忆以及过往状态，不必初始化
	virtual void resetMemory()=0;
	//
	virtual inline u_sample procDsp(u_sample v)=0;
	virtual inline void procDsp(u_sample * input, u_sample * output){
		*output=procDsp(*input);
	}
	virtual inline void procBlock(u_sample * input, u_sample * output, u_index length){
		for(u_index i=0;i < length;i++){
			procDsp(input + i, output + i);
		}
	}
	inline void procBlock(u_sample * inputAsOutput, u_index length){
		procBlock(inputAsOutput, inputAsOutput, length);
	}
	virtual yzrilyzr_lang::String toString()const override{
		return "DSP";
	}
	};
	typedef std::shared_ptr<DSP> DSPPtr;
}